cd "...\data set folder" /* define the directory where the replication package is */
log using "log_moon_souva_2016.smcl", replace


/* Audience Costs, Domestic Economy, and Coercive Diplomacy */
/* replication code */
set more off
set scheme s1manual


/* open Moon and Souva (2016) data */
/* GDP growth rate data already merged */
use "data_moon_souva_2016.dta", clear


/* histgram */
hist growthrate, xtitle(Annual GDP growth)
graph save Graph hist1.gph, replace
hist growthrate_bi, xtitle(Biannual GDP growth)
graph save Graph hist2.gph, replace
hist growthrate_pc, xtitle(Annual per-capita GDP growth)
graph save Graph hist3.gph, replace
hist growthrate_pc_bi, xtitle(Biannual per-capita GDP growth)
graph save Graph hist4.gph, replace
graph combine hist1.gph hist2.gph hist3.gph hist4.gph, scale(1.25)
graph save Graph figure1.gph, replace

hist growthrate, xtitle(Annual GDP growth), if nomctstrataccd==1
graph save Graph hist1_con.gph, replace
hist growthrate_bi, xtitle(Biannual GDP growth), if nomctstrataccd==1
graph save Graph hist2_con.gph, replace
hist growthrate_pc, xtitle(Annual per-capita GDP growth), if nomctstrataccd==1
graph save Graph hist3_con.gph, replace
hist growthrate_pc_bi, xtitle(Biannual per-capita GDP growth), if nomctstrataccd==1
graph save Graph hist4_con.gph, replace
graph combine hist1_con.gph hist2_con.gph hist3_con.gph hist4_con.gph, scale(1.25)
graph save Graph figure2.gph, replace


/* analysis */
set more off
logit failure_100_ks nomctstrataccd mctstrataccd mctstratnoaccd majmaj_ks majmin_ks minmaj_ks capshare_a_ks ///
	contig_ks swt_dyad tau_lead_a tau_lead_b, robust cluster(mct_code) level(90), if growthrate!=.
outreg2 using "result.doc", stats(coef pval) symbol(*) alpha(0.1)

logit failure_100_ks i.nomctstrataccd##c.growthrate mctstrataccd mctstratnoaccd majmaj_ks majmin_ks minmaj_ks capshare_a_ks ///
	contig_ks swt_dyad tau_lead_a tau_lead_b, robust cluster(mct_code) level(90)
outreg2 using "result.doc", stats(coef pval) symbol(*) alpha(0.1)
margins, dydx(nomctstrataccd) at(growthrate=(-.45(.1).25)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Annual GDP growth") yline(0, lpattern(dash))
graph save figurea1_1.gph, replace

logit failure_100_ks i.nomctstrataccd##c.growthrate_bi mctstrataccd mctstratnoaccd majmaj_ks majmin_ks minmaj_ks capshare_a_ks ///
	contig_ks swt_dyad tau_lead_a tau_lead_b, robust cluster(mct_code) level(90)
outreg2 using "result.doc", stats(coef pval) symbol(*) alpha(0.1)
margins, dydx(nomctstrataccd) at(growthrate_bi=(-.3(.1).3)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Biannual GDP growth") yline(0, lpattern(dash))
graph save figurea1_2.gph, replace

logit failure_100_ks i.nomctstrataccd##c.growthrate_pc mctstrataccd mctstratnoaccd majmaj_ks majmin_ks minmaj_ks capshare_a_ks ///
	contig_ks swt_dyad tau_lead_a tau_lead_b, robust cluster(mct_code) level(90)
outreg2 using "result.doc", stats(coef pval) symbol(*) alpha(0.1)
margins, dydx(nomctstrataccd) at(growthrate_pc=(-.50(.1).2)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Annual per-capita GDP growth") yline(0, lpattern(dash))
graph save figurea1_3.gph, replace

logit failure_100_ks i.nomctstrataccd##c.growthrate_pc_bi mctstrataccd mctstratnoaccd majmaj_ks majmin_ks minmaj_ks capshare_a_ks ///
	contig_ks swt_dyad tau_lead_a tau_lead_b, robust cluster(mct_code) level(90)
outreg2 using "result.doc", stats(coef pval) symbol(*) alpha(0.1)
margins, dydx(nomctstrataccd) at(growthrate_pc_bi=(-.3(.1).3)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Biannual per-capita GDP growth") yline(0, lpattern(dash))
graph save figurea1_4.gph, replace

graph combine figurea1_1.gph figurea1_2.gph figurea1_3.gph figurea1_4.gph, title("")
graph save figurea1.gph, replace


log close

clear
